<template>
	<uni-popup type="bottom" ref="accountRefs">
		<view class="uni_account pb30">
			<view class="dis_center">
				<text class="fs28 pt15 pb15">账户选择</text>
			</view>
			<view class="dis_center_s p20" @click="selected(item)" v-for="item in options" :key="item.value">
				<text class="fs28">{{ item.text }}</text>
				<UniCheckbox :checked="checked === item.value" :width="26" color="red"/>
			</view>
		</view>
	</uni-popup>
</template>

<script>
	import UniCheckbox from '../uni-checkbox/index.vue'
	export default {
		components: {
			UniCheckbox
		},
		props: {
			options: {
				type: Array,
				default: () => []
			},
			value: {
				type: String,
				default: ''
			}
		},
		data() {
			return {
				checked: ''
			}
		},
		created() {
				this.checked = this.value
		},
		methods: {
			open() {
				this.$refs.accountRefs.open()
			},
			close() {
				this.$refs.accountRefs.close()
			},
			selected(item) {
				this.checked = item.value
				this.$emit('selected', item.value)
				this.close()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.uni_account {
		background-color: #fff;
	}
</style>